﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
//using System.Xml.Linq;

using YouHP.BLL;
using YouHP.Model;
using YouHP.Model.Group;
using YouHP.Utility;
using System.Data.SqlTypes;

namespace web.admin
{
    public partial class RecommendUserListEdit: System.Web.UI.Page
    {
        private RecommendUserBLL recommendUserBLL = RecommendUserBLL.Instance;
        private static RecommendUserInfo recommendUserInfo = new RecommendUserInfo();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Bind();
            }
            
        }
        protected void CancelButton_click(object sender, EventArgs e)
        {
            Response.Redirect("RecommendedUserList.aspx");
        }
        protected void InsertButton_click(object sender, EventArgs e)
        {
            RecommendUserInfo updateRecommendUserInfo = validateForm(recommendUserListEdit);
            bool succ = recommendUserBLL.RecommendUserUpdate(updateRecommendUserInfo);
            Response.Redirect("RecommendedUserList.aspx");
        }
        protected void DataBound(object sender, EventArgs e)
        {

        }
        protected void Bind()
        {
            try
            {
                int id = RequestTools.GetQueryInt("id", -1);
                if (id > 0)
                {
                    IList list = new ArrayList();
                    recommendUserInfo = recommendUserBLL.RecommendUserGet(id);
                    list.Add(recommendUserInfo);
                    this.recommendUserListEdit.DataSource = list;
                    this.recommendUserListEdit.DataBind();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private RecommendUserInfo validateForm(DetailsView formViewCtl)
        {
            RecommendUserInfo updatedRecommendUserInfo = new RecommendUserInfo();
            updatedRecommendUserInfo.Id = recommendUserInfo.Id;
            updatedRecommendUserInfo.diseasename = ((TextBox)formViewCtl.FindControl("疾病名")).Text;
            updatedRecommendUserInfo.username = ((TextBox)formViewCtl.FindControl("用户名")).Text;

            //updatedNewsInfo.Body = ((TextBox)formViewCtl.FindControl("body")).Text;
            return updatedRecommendUserInfo;
        }
    }
}
